#!/bin/bash

# 设置 Docker 镜像加速器
echo '{"registry-mirrors": ["https://docker.1ms.run"]}' | sudo tee /etc/docker/daemon.json > /dev/null

# 重新加载 systemd 配置并重启 Docker 服务
sudo systemctl daemon-reload
sudo systemctl restart docker

# 拉取 Docker 镜像
docker pull mysql:8.0.32
if [ $? -ne 0 ]; then
    echo "Failed to pull mysql:8.0.32"
    exit 1
fi

docker pull redis:latest
if [ $? -ne 0 ]; then
    echo "Failed to pull redis:latest"
    exit 1
fi

docker pull registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:v0.7.0
if [ $? -ne 0 ]; then
    echo "Failed to pull registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:v0.7.0"
    exit 1
fi

docker pull registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.18
if [ $? -ne 0 ]; then
    echo "Failed to pull registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.18"
    exit 1
fi

docker pull registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:latest
if [ $? -ne 0 ]; then
    echo "Failed to pull registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:latest"
    exit 1
fi

docker pull registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.10
if [ $? -ne 0 ]; then
    echo "Failed to pull registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.10"
    exit 1
fi

docker pull registry.cn-hangzhou.aliyuncs.com/fastgpt/mysql:8.0.36
if [ $? -ne 0 ]; then
    echo "Failed to pull registry.cn-hangzhou.aliyuncs.com/fastgpt/mysql:8.0.36"
    exit 1
fi

docker pull registry.cn-hangzhou.aliyuncs.com/fastgpt/one-api:v0.6.6
if [ $? -ne 0 ]; then
    echo "Failed to pull registry.cn-hangzhou.aliyuncs.com/fastgpt/one-api:v0.6.6"
    exit 1
fi

docker pull prom/prometheus:latest
if [ $? -ne 0 ]; then
    echo "Failed to pull prom/prometheus:latest"
    exit 1
fi

docker pull grafana/grafana:latest
if [ $? -ne 0 ]; then
    echo "Failed to pull grafana/grafana:latest"
    exit 1
fi

docker pull prom/node-exporter:latest
if [ $? -ne 0 ]; then
    echo "Failed to pull prom/node-exporter:latest"
    exit 1
fi

docker pull ipfs/kubo:release
if [ $? -ne 0 ]; then
    echo "Failed to pull ipfs/kubo:release"
    exit 1
fi

docker pull nginx:1.21.6
if [ $? -ne 0 ]; then
    echo "Failed to pull nginx:1.21.6"
    exit 1
fi

docker pull fiscoorg/dataexport:1.7.2
if [ $? -ne 0 ]; then
    echo "Failed to pull fiscoorg/dataexport:1.7.2"
    exit 1
fi

echo "All images pulled successfully."